﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master"
    CodeBehind="BeachDetails.aspx.vb" Inherits="BeachesInGreeceComplete.BeachDetails" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
        ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT [ID], [BeachName] FROM [Beaches] WHERE ([ID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <div class="Picture">
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource2">
            <ItemTemplate>
                <h2>
                    <%# Eval("BeachName") %></h2>
            </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <img src='<%# Eval("Picture") %>' alt="No Picture" width="300" height="250" />
            </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:Repeater ID="Repeater6" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                Posted •
                <asp:Label ID="lbl_Time" runat="server" Text='<%# CalculateTime.calculateTime(Eval("DateAdded")) %>'
                    ForeColor="#009999" />
                • Total Views 
                    <asp:Label ID="lbl_Views" runat="server" Text='<%# getViews(Eval("ID")) %>' CssClass="myButton" />
            </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:Repeater ID="Repeater7" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                By •
                <asp:HyperLink ID="HyperLink2" runat="server" Text='<%# Eval("Tourist")%>' NavigateUrl='<%# Eval("Tourist", "Profile.aspx?Tourist={0}") %>'
                    ForeColor="Red" Font-Bold="True" CssClass="red" Font-Size="Smaller">
                    <asp:Label ID="TouristLabel" CssClass="BeachNameLabel" runat="server" Text='<%# Eval("Tourist") %>' />
                </asp:HyperLink><br />
            </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <span class="FavoriteButton">
                    <asp:Button ID="btn_Favorites" runat="server" Text="Add As Favorite" CssClass="m-btn blue" /></span>
                <span class="LikeButton">
                    <asp:Button ID="btn_Likes" runat="server" Text="Like it!" CssClass="m-btn purple" />
                    <asp:Repeater ID="rpt_Likes" runat="server" DataSourceID="SqlDataSource9">
                        <ItemTemplate>
                            • <span id="Span1" runat="server" title='<%# Eval("TotalLikes") & " Likes" %>'>
                                <asp:Label ID="lbl_Views" runat="server" Text='<%# Eval("TotalLikes") %>' CssClass="myButton" /></span>
                        </ItemTemplate>
                    </asp:Repeater>
                    <asp:SqlDataSource ID="SqlDataSource9" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [TotalLikesPerBeach] WHERE ([ID] = ?)">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="Beach_FK" QueryStringField="ID" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </span>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <asp:SqlDataSource ID="SqlDataSource8" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
        ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [BeachAverageRating] WHERE ([Beach_FK] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="Beach_FK" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <div class="BasicInformation">
        <br />
        <br />
        <h3>
            Description</h3>
        <br />
        <br />
        <div id="Description">
            <asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource1">
                <ItemTemplate>
                    <%# Eval("Description") %>
                </ItemTemplate>
            </asp:Repeater>
        </div>
        <h3>
            Review</h3>
        <br />
        <br />
        <div id="Review">
            <asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource1">
                <ItemTemplate>
                    <%# Eval("Review") %>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
        ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT [ID], [Description], [BeachName], [Review], [UserRating], [Picture], [Tourist], [DateAdded] FROM [Beaches] WHERE ([ID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <div class="Ratings">
        <br />
        <br />
        <h3>
            Rating&emsp;<asp:Image ID="img_Flag" runat="server" ToolTip="This beach has been awarded with a blue flag" /></h3>
        <br />
        <br />
        <asp:Label ID="Label1" CssClass="RatingNameLabel1" runat="server" Text="Average Rating" />
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
                <asp:Repeater ID="Repeater5" runat="server" DataSourceID="SqlDataSource7">
                    <ItemTemplate>
                        <div class="ImageRating">
                            <img src='<%# getRating(Eval("AverageRating")) %>' alt="No picture found" width="120"
                                height="30" /></div>
                    </ItemTemplate>
                </asp:Repeater>
                <asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [BeachAverageRating] WHERE ([Beach_FK] = ?)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Beach_FK" QueryStringField="ID" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [BeachUserRating] WHERE ([Beach_FK] = ?) AND ([Tourist] = @Tourist)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Beach_FK" QueryStringField="ID" Type="Int32" />
                        <asp:Parameter Name="Tourist" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:Label ID="TouristLabel" CssClass="RatingNameLabel1" runat="server" Text="Your Rating" />
                <asp:Repeater ID="Repeater9" runat="server" DataSourceID="SqlDataSource5" Visible="false">
                    <ItemTemplate>
                        <div class="ImageRating">
                            <img src='<%# getRating(Eval("UserRating")) %>' alt="No picture found" width="120"
                                height="30" /></div>
                    </ItemTemplate>
                </asp:Repeater>
                <asp:Button ID="btn_Change" runat="server" Text="Change your Rating!" CssClass="m-btn blue"
                    Visible="false" />
                <ajaxToolkit:Rating ID="Rating1" runat="server" EmptyStarCssClass="emptypng" FilledStarCssClass="smileypng"
                    StarCssClass="smileypng" WaitingStarCssClass="donesmileypng" HorizontalAlign="Left">
                </ajaxToolkit:Rating>
                <p>
                    <asp:Button ID="btn_Rating" runat="server" Text="Rate it!" CssClass="m-btn blue" />
                </p>
            </ContentTemplate>
        </asp:UpdatePanel>
        <hr />
    </div>
    <div class="Likes">
        <h5>
            Beaches with similar rating</h5>
        <br />
        <br />
        <asp:UpdatePanel ID="UpdatePanel4" runat="server">
            <ContentTemplate>
                <asp:Repeater ID="ParentRepeater" runat="server" DataSourceID="SqlDataSource10">
                    <ItemTemplate>
                        <a id="RepeaterStyle" href="BeachDetails.aspx?ID=<%# Eval("ID") %>">
                            <%# Eval("BeachName")%></a>
                    </ItemTemplate>
                </asp:Repeater>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:SqlDataSource ID="SqlDataSource10" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
            ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT TOP 3 * FROM BeachesWithAverageRating WHERE AverageRating = @AverageRating AND ID <> ?">
            <SelectParameters>
                <asp:Parameter Name="@AverageRating" />
                <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <h5>
            Beaches close to this</h5>
        <br />
        <br />
        <asp:Repeater ID="Repeater8" runat="server" DataSourceID="SqlDataSource11">
            <ItemTemplate>
                <a id="RepeaterStyle" href="BeachDetails.aspx?ID=<%# Eval("ID") %>">
                    <%# Eval("BeachName")%></a>
            </ItemTemplate>
        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource11" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
            ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT TOP 3 ID, BeachName FROM Beaches WHERE Region = @Region AND ID <> ? ORDER BY ID DESC">
            <SelectParameters>
                <asp:Parameter Name="@Region" />
                <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    <div class="CommentsDetailsArea">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <h2>
                    <%= getTotalComments() %></h2>
                <table>
                    <tr>
                        <td>
                            Title
                        </td>
                        <td>
                            <asp:TextBox ID="tb_Title" runat="server"></asp:TextBox><asp:RequiredFieldValidator
                                ID="RequiredFieldValidator1" runat="server" ControlToValidate="tb_Title" CssClass="field-validation-error"
                                ErrorMessage="*" ValidationGroup="CommentGroup"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Comment
                        </td>
                        <td>
                            <asp:TextBox ID="tb_Comment" runat="server" TextMode="MultiLine" Height="75px" Width="300px"></asp:TextBox><asp:RequiredFieldValidator
                                ID="RequiredFieldValidator2" runat="server" ControlToValidate="tb_Comment" CssClass="field-validation-error"
                                ErrorMessage="*" ValidationGroup="CommentGroup"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table>
                <asp:Button ID="btn_Comment" runat="server" CommandArgument="0" OnClick="Button_Click"
                    Text="Add Comment" ValidationGroup="CommentGroup" CssClass="m-btn blue" />
                <hr />
                <div id="ContentWraper">
                    <asp:Literal ID="CommentsLtr" runat="server"></asp:Literal></div>
                <br />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="TagsArea">
        <div id="TagContentWraper">
            <h2>
                Tags</h2>
            <asp:UpdatePanel runat="server">
                <ContentTemplate>
                    <div class="CloudBox">
                        <asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                            ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT BeachTagJunction.Tag_FK, Count(BeachTagJunction.Tag_FK) AS TotalTags, Tags.Tag, BeachTagJunction.Beach_FK
                            FROM Tags INNER JOIN BeachTagJunction ON (Tags.ID = BeachTagJunction.Tag_FK) WHERE (BeachTagJunction.Beach_FK = ?)
                            GROUP BY BeachTagJunction.Tag_FK, Tags.Tag, BeachTagJunction.Beach_FK">
                            <SelectParameters>
                                <asp:QueryStringParameter Name="BeachTagJunction.Beach_FK" QueryStringField="ID"
                                    Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <asp:Literal ID="CloudTags" runat="server"></asp:Literal></div>
                    <asp:CheckBoxList ID="cbl_Tags" runat="server" DataSourceID="SqlDataSource4" DataTextField="Tag"
                        DataValueField="ID" RepeatDirection="Horizontal" RepeatColumns="3">
                    </asp:CheckBoxList>
                    <br />
                    Enter new tags, separated by (",")
                    <br />
                    <asp:TextBox ID="tb_Tags" runat="server"></asp:TextBox><asp:SqlDataSource ID="SqlDataSource4"
                        runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT [ID], [Tag] FROM [Tags]">
                    </asp:SqlDataSource>
                    <br />
                    <asp:Button ID="btn_Tag" runat="server" Text="Tag" CssClass="m-btn blue" />
                    <asp:Label ID="lbl_Tag" runat="server" CssClass="error"></asp:Label><br />
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        <br />
        <div>
            <h3>
                <span class="show_hide">Activities</span> - <span class="show_hide2">Bars</span>
                - <span class="show_hide3">Hotels</span></h3>
            <div class="slidingDiv">
                <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                    <ContentTemplate>
                        <asp:Repeater ID="Repeater10" runat="server" DataSourceID="SqlDataSource3">
                            <HeaderTemplate>
                                <b>Activities</b><br />
                                <br />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <a id="RepeaterStyle" href="BeachesByActivity.aspx?ActivityName=<%# Eval("ActivityName") %>">
                                    <%# Eval("ActivityName")%></a>
                            </ItemTemplate>
                        </asp:Repeater>
                        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                            ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT * FROM [Activities] WHERE ([Beaches_FK] = ?)">
                            <SelectParameters>
                                <asp:QueryStringParameter Name="Beaches_FK" QueryStringField="ID" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <br />
                        <br />
                        Enter new activities, separated by (",")
                        <br />
                        <asp:TextBox ID="tb_Activities" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                            CssClass="field-validation-error" ErrorMessage="*" 
                            ControlToValidate="tb_Activities" ValidationGroup="Activities"></asp:RequiredFieldValidator>
                        <br />
                       
                        <asp:Button ID="btn_AddActivity" runat="server" Text="Add Activity" CssClass="m-btn blue" ValidationGroup="Activities"/>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <p class="show_hide">
                    hide</p>
            </div>
            <div class="slidingDiv2">
                <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                <ContentTemplate>
                <asp:Repeater ID="Repeater11" runat="server" DataSourceID="SqlDataSource12">
                    <HeaderTemplate>
                        <b>Bar - Restaurant - Coffee</b><br />
                        <br />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <span id="RepeaterStyle">
                            <%# Eval("CafeName")%></span> <span id="RepeaterStyle2">
                                <%#getTypeForPlace(Eval("Restaurant"), Eval("Coffee"), Eval("Bar") )%></span>
                        <br />
                    </ItemTemplate>
                </asp:Repeater>
                <asp:SqlDataSource ID="SqlDataSource12" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT * FROM [Cafes_Restaurant] WHERE ([Beaches_FK] = ?)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Beaches_FK" QueryStringField="ID" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                 <table>
                <tr>
                    <td>
                        Name</td>
                    <td>
                        <asp:TextBox ID="tb_Food" runat="server" ViewStateMode="Enabled"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                            ControlToValidate="tb_Food" CssClass="field-validation-error" ErrorMessage="*" ValidationGroup="Food"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Type</td>
                    <td>
                        <asp:CheckBoxList ID="cbl_Food" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="Restaurant">Restaurant</asp:ListItem>
                            <asp:ListItem Value="Coffee">Coffee</asp:ListItem>
                            <asp:ListItem Value="Bar">Bar</asp:ListItem>
                        </asp:CheckBoxList>
                        <asp:Label ID="lbl_ChooseType" runat="server" CssClass="field-validation-error" ></asp:Label>
                    </td>
                </tr>
        </table>
           
            <asp:Button ID="btn_AddFood" runat="server" Text="Add Food/Drink" CssClass="m-btn blue" ValidationGroup="Food"/>
            </ContentTemplate>
                </asp:UpdatePanel>
                <p class="show_hide2">
                    hide</p>
            </div>
            <div class="slidingDiv3">
                <asp:UpdatePanel ID="UpdatePanel7" runat="server">
                <ContentTemplate>
                <asp:Repeater ID="Repeater12" runat="server" DataSourceID="SqlDataSource13">
                    <HeaderTemplate>
                        <b>Hotels</b><br />
                        <br />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <span id="RepeaterStyle">
                            <%# Eval("HotelName")%></span> <span id="RepeaterStyle2">
                                <%# isRecommended(Eval("IsRecommended"))%></span>
                        <br />
                        •<span id="RepeaterStyle3"><%# Eval("Facilities")%></span>
                        <br />
                    </ItemTemplate>
                </asp:Repeater>

                <asp:SqlDataSource ID="SqlDataSource13" runat="server" ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [Hotels] WHERE ([Beach_FK] = ?)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Beaches_FK" QueryStringField="ID" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>

                <table>
                <tr>
                    <td>
                        Hotel Name</td>
                    <td>
                        <asp:TextBox ID="tb_HotelName" runat="server" ViewStateMode="Enabled"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                            CssClass="field-validation-error" ErrorMessage="*" 
                            ControlToValidate="tb_HotelName" ValidationGroup="Hotels"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Recommended</td>
                    <td>
                        <asp:RadioButtonList ID="rbl_Hotel" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Selected="True" Value="-1">Yes</asp:ListItem>
                            <asp:ListItem Value="0">No</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                 <tr>
                    <td>
                        Facilities</td>
                    <td>
                        <asp:TextBox ID="tb_Facilities" runat="server" ViewStateMode="Enabled"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" 
                            CssClass="field-validation-error" ErrorMessage="*" 
                            ControlToValidate="tb_Facilities" ValidationGroup="Hotels"></asp:RequiredFieldValidator>
                    </td>
                </tr>
        </table>
        
        <asp:Button ID="btn_Hotel" runat="server" Text="Add Hotel" CssClass="m-btn blue" ValidationGroup="Hotels"/>
        </ContentTemplate>
                </asp:UpdatePanel>
                <p class="show_hide3">
                    hide</p>
            </div>
        </div>
    </div>
    <script src="Scripts/ShowHide.js" type="text/javascript"></script>
</asp:Content>
